home *** CD-ROM | disk | FTP | other *** search
- property railRects, railLocs, railRots, railPos, railSprites, trainSprites, TrainDrag, occuPiedList, orgList, wholeTrain
-
- on new me
- railRects = [rect(350, 244, 450, 344), rect(396, 177, 516, 297), rect(286, 294, 406, 414), rect(281, 181, 401, 301), rect(395, 289, 515, 409), rect(99, 142, 329, 232), rect(465, 135, 695, 225), rect(102, 367, 332, 457), rect(469, 359, 699, 449), rect(650, 177, 740, 407), rect(58, 186, 148, 416)]
- railLocs = [point(535, 169), point(604, 163), point(666, 194), point(706, 250), point(708, 318), point(677, 381), point(618, 416), point(549, 416), point(491, 377), point(336, 236), point(282, 191), point(217, 167), point(150, 183), point(99, 232), point(83, 299), point(102, 366), point(150, 415), point(217, 430), point(284, 413), point(336, 363), point(484, 205)]
- railRots = [-17, 12, 44, 76, 107, 137, 172, 199, 226, 226, 219, 186, 156, 126, 94, 64, 34, 4, -29, -42, -42]
- railPos = [10, 20, 30, 40, 50, 60, 70, 80, 90, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 250]
- railSprites = []
- trainSprites = []
- TrainDrag = 0
- return me
- end
-
- on reportTrainFrame me
- bigFrame = sprite(trainSprites[1]).frame
- smallFrame = integer(bigFrame * 0.59999999999999998)
- sprite(wholeTrain).frame = smallFrame
- sprite(wholeTrain).loc = point(400, 300)
- end
-
- on reportSprites me, pSprite, typeX
- if typeX = "railSprites" then
- railSprites[railSprites.count + 1] = pSprite
- else
- if typeX = "trainSprites" then
- trainSprites[trainSprites.count + 1] = pSprite
- else
- if typeX = "wholeTrain" then
- wholeTrain = pSprite
- end if
- end if
- end if
- end
-
- on takeRect me, pRect
- if railRects.count > 0 then
- X = 0
- repeat with n = 1 to railRects.count
- if pRect = railRects[n] then
- X = 1
- if X = 1 then
- railRects.deleteOne(pRect)
- exit repeat
- end if
- end if
- end repeat
- end if
- if railRects = [] then
- go("train")
- end if
- return X
- end
-
- on getTrainLoc me, pLoc
- locDifList = []
- repeat with n = 1 to railLocs.count
- if pLoc[1] > railLocs[n][1] then
- A = pLoc[1] - railLocs[n][1]
- else
- A = railLocs[n][1] - pLoc[1]
- end if
- if pLoc[2] > railLocs[n][2] then
- b = pLoc[2] - railLocs[n][2]
- else
- b = railLocs[n][2] - pLoc[2]
- end if
- locDifList[locDifList.count + 1] = A + b
- end repeat
- smallest = 10000
- repeat with n = 1 to locDifList.count
- if locDifList[n] < smallest then
- smallest = locDifList[n]
- position = n
- end if
- end repeat
- check = 0
- if voidp(occuPiedList) = 0 then
- repeat with n = 1 to occuPiedList.count
- if occuPiedList[n] = railPos[position] then
- check = 1
- exit repeat
- end if
- end repeat
- end if
- if check = 0 then
- lastLoc = railLocs[position]
- lastRot = railRots[position]
- lastFrameX = railPos[position]
- return [lastLoc, lastRot, lastFrameX]
- else
- return [0]
- end if
- end
-
- on placeRects me
- repeat with n = 1 to railRects.count
- sprite(railSprites[n]).rect = railRects[n]
- sprite(railSprites[n]).placed = 1
- end repeat
- go("train")
- end
-
- on order me
- tramNum = trainSprites.count
- if tramNum > 1 then
- orgList = trainSprites * 1
- sprites = [orgList[1]]
- orgList.deleteAt(1)
- sound(1).play(member("motor4", 1))
- repeat with n = 1 to tramNum - 1
- v = 0
- search(me, orgList[1], orgList[orgList.count], sprite(sprites[sprites.count]).frame)
- v = the result
- if v > 30 then
- sprites[sprites.count + 1] = v
- next repeat
- end if
- cCount = sprites.count + 1
- repeat while sprites.count < cCount
- q = sprites.count
- repeat with b = 1 to q
- sprite(sprites[b]).frame = sprite(sprites[b]).frame - 10
- if sprite(sprites[b]).frame = 1 then
- sprite(sprites[b]).frame = 250
- end if
- end repeat
- updateStage()
- search(me, orgList[1], orgList[orgList.count], sprite(sprites[sprites.count]).frame)
- v = the result
- if v > 30 then
- sprites[sprites.count + 1] = v
- end if
- end repeat
- end repeat
- sound(1).stop()
- sound(1).play(member("connect", 1))
- updateStage()
- repeat while soundBusy(1)
- end repeat
- makeOccupiedList(me, sprites)
- end if
- end
-
- on makeOccupiedList me, sprites
- occuPiedList = []
- repeat with n = 1 to sprites.count
- occuPiedList[n] = sprite(sprites[n]).frame
- end repeat
- end
-
- on search me, fromSprite, toSprite, frameX
- yFound = 0
- if frameX < 11 then
- frameY = 250 + frameX - 10
- else
- frameY = frameX - 10
- end if
- repeat with n = fromSprite to toSprite
- if sprite(n).frame = frameY then
- xSprite = n
- yFound = 1
- orgList.deleteOne(n)
- exit repeat
- end if
- end repeat
- if yFound = 1 then
- return xSprite
- end if
- end
-